version: '3'

volumes:
  pg_data:
  static:
  static_backend:
  media:

services:
  db:
    image: postgres:13
    env_file: .env
    volumes:
      - pg_data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: your_password

  backend:
    image: d1g1tsdocker/foodgram_backend:latest
    env_file: .env
    depends_on:
      - db
    volumes:
      - static_backend:/app/collected_static
      - media:/app/media
      - /home/foodgram/api/docs:/app/api/docs

  frontend:
    image: d1g1tsdocker/foodgram_frontend:latest
    env_file: .env
    command: cp -r /app/build/. /frontend_static/
    volumes:
      - static:/frontend_static
    depends_on:
      - backend

  gateway:
    image: d1g1tsdocker/foodgram_infra:latest
    env_file: .env
    depends_on:
      - backend
      - frontend
    volumes:
      - static:/staticfiles/
      - static_backend:/collected_static
      - media:/media
      - /home/foodgram/api/docs:/api/docs
    ports:
      - 8000:80